package com.example.teaching_server.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 映射/uploads/** 到文件上传目录
        registry.addResourceHandler("/uploads/**")
                .addResourceLocations("file:./uploads/");

        // 如果是生产环境，使用绝对路径
        // registry.addResourceHandler("/uploads/**")
        //         .addResourceLocations("file:/mnt/mycfs/uploads/");
    }
}
